package com.tms.app.tms.ui;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.tms.app.tms.ui.base.ui.BaseListActivity;
import com.tms.app.tms.R;
import com.tms.app.tms.adapter.WayBillAdapter;
import com.tms.app.tms.ui.base.view.IListView;
import com.tms.app.tms.widget.CustomLoadMoreView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/10/28 0028.
 * 运单列表
 */

public class WaybillListAc extends BaseListActivity implements IListView {
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.swipeLayout)
    SwipeRefreshLayout swipeLayout;
    private WayBillPAbs taskInfoP;
    private int planId;
    private int planIdShowType=-1;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_layout_waybill);
        ButterKnife.bind(this);
        taskInfoP = new WayBillPAbs();
        adapter=new WayBillAdapter();
        initView();

        setToolBarTitle("运单列表",-1, -1);
        planId = getIntent().getIntExtra("planId", 0);
        planIdShowType=getIntent().getIntExtra("planIdShowType",-1);
        taskInfoP.setiView(this);
        taskInfoP.setPlanIdShowType(planIdShowType);
        if (planId==0)
            finish();
        taskInfoP.getData(token,planId);
        showLoadingDialog();
    }




    public void initView() {
        swipeLayout.setColorSchemeColors(Color.rgb(47, 223, 189));
        swipeLayout.setOnRefreshListener(taskInfoP);
       // customLoadMoreView = new CustomLoadMoreView();
       // homeAdapter = new WayBillAdapter();
       // adapter.setLoadMoreView(customLoadMoreView);
        adapter.setOnItemChildClickListener(taskInfoP);
        adapter.setOnItemClickListener(taskInfoP);
      //  adapter.setOnLoadMoreListener(taskInfoP, recyclerView);
        // GridLayoutManager mgr=new GridLayoutManager(getContext(),3);
        LinearLayoutManager mgr = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(mgr);
        recyclerView.setNestedScrollingEnabled(false);
        recyclerView.setAdapter(adapter);
    }


    @Override
    public void refreshComplite(String... msg) {
        super.refreshComplite(msg);
        swipeLayout.setRefreshing(false);

    }

    @Override
    public void refreshNoData(String... msg) {
        super.refreshNoData(msg);
        swipeLayout.setRefreshing(false);
    }
}
